package edu.kit.aifb.ruleintegrator.bayes.network;

import java.util.HashMap;
import java.util.Map;

import cc.mallet.grmm.types.Assignment;

public class NoisyOrFactor extends Factor{
	private double m_lambda0=0.0;
	
	private Map<RandomVariable,Double> m_lambdas;
	
	public NoisyOrFactor(){
		m_lambdas=new HashMap<RandomVariable, Double>();
		
	}
	
	public double getBaseLambda(){
		return this.m_lambda0;
		
	}
	
	public void setBaseLambda(double lambda0){
		this.m_lambda0=lambda0;
	}
	
	public Map<RandomVariable,Double> getLambdas(){
		return this.m_lambdas;
	}
	
	public double compute(Map<RandomVariable,Integer> assignments){
		double total=1.0-m_lambda0;
		for(RandomVariable var:assignments.keySet()){
			total*=Math.pow(1.0-m_lambdas.get(var),assignments.get(var));
		}
		return 1.0-total;
	}

}
